package com.tz.test.service.impl;

import com.tz.test.entity.User;
import com.tz.test.handle.MqMessageHandle;
import com.tz.test.mapper.UserMapper;
import com.tz.test.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zhangky
 * @since 2020/4/20
 */
@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Resource
    private MqMessageHandle mqMessageHandle;

    @Override
    public List<User> getAllUsers() {
        List<User> allUsers = userMapper.getAllUsers();
        try {
            mqMessageHandle.handleMessage(allUsers);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return allUsers;
    }

    @Override
    public void show(String name) {
        System.out.println("代理对象的show方法执行了--" + name);
    }

    @Override
    public void display() {
        System.out.println("代理对象的display方法执行了");
    }

    @Override
    public void testMethod() {
        System.out.println("代理对象的testMethod方法执行了");
    }
}
